草庐IT

sqlite - Symfony2 : Unit testing with sqlite

全部标签

php - symfony2 中的自定义异常行为

我试图找出如何制作自定义异常行为。当我使用抛出异常时thrownew\Exception('Erroroccurredwithyourrequestpleasetryagain');我自动获得状态500和消息作为内部服务器错误但是我希望我的响应包含我的异常消息,而不仅仅是内部服务器错误,以便它显示如下内容:{"error":{"code":500,"message":"Erroroccurredwithyourrequestpleasetryagain"}}最重要的是可能会做一些额外的事情,例如通过电子邮件将错误发​​送给自己。但是,我只希望在抛出\Exception而不是使用类似的东

php - 在 Symfony2 中从 AuthenticationHandler 设置 flashMessage

我在使用FOSUserBundle时遇到问题,因为每当我使用错误的凭据登录时,我都会收到完整的堆栈跟踪信息作为错误消息:Error!exception'Symfony\Component\Security\Core\Exception\BadCredentialsException'withmessage'Badcredentials'in/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.p

php - 从 Controller Symfony2 中的 URL 获取参数

我尝试通过get方法提交我的表单,但是在Controller中我无法获取值,这里是Controller:var_dump($request->query->get('startPoint'));//itsNULL我的表格:{{form_widget(search_form,{'attr':{'class':'search_form'}})}}生成的网址:http://example.com/app_dev.php/search_trips?search_form%5BstartPoint%5D=3123123&search_form%5BendPoint%5D=&search_form

php - Symfony2 - 为服务指定的类型名称不匹配

我尝试使用我自己的ImageType配置EasyAdminBundle,以在我的ArticleType中上传文件。所以我在app\config\services.yml中创建了这个服务:services:oah_news_form_type_image:class:OAH\NewsBundle\Form\ImageTypetags:[{name:form.type,alias:'oah_news_form_type_image'}]并尝试在我的app\config\config.yml中调用它:easy_admin:entities:Article:class:OAH\NewsBund

php - Symfony 异常 : value required for $request argument

我有一个看起来像这样的loginAction:publicfunctionloginAction(Request$request){if($request->getMethod()=='POST'){$mail=$request->getContent('umail');$pass=$request->getContent('upass');$em=$this->getDoctrine()->getManager();$rep=$em->getRepository('SystemBundle:User');$user=$rep->findOneBy(array("email"=>$ma

php - 如何在 Symfony 2.7 中关闭用户的所有 session ?

用户更改密码后(在恢复密码操作中),我需要使所有连接到该用户的session无效(他可能登录了多个浏览器/设备)。因此,在我将使用新密码的用户保存在数据库中之后,我需要关闭该用户在不同浏览器/设备中可能处于事件状态的所有session。我试过这个:$token=newUsernamePasswordToken($user,null,'main',$user->getRoles());$this->get('security.token_storage')->setToken($token);还试过:$this->get('security.token_storage')->getTok

php - Doctrine - Symfony 查询错误

我确实有一个错误,但我不知道如何修复它。$query=$entityManager->createQuery("UPDATEAppBundle:ChangeAPISET`key`='asd123'WHERE`id`=1");$query->execute();我的AppBundle:ChangeAPI/***@ORM\Entity*@ORM\Table(name="api")*/classChangeAPI{/***@ORM\Column(type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AUTO")*/protected$id

php - Symfony 4 中的注解

我尝试使用Symfony4进行开发,所以我遵循symfony.com上的教程当我尝试访问:时出现错误http://localhost:8000/这是错误:[SyntaxError]ExpectedPlainValue,got'''atposition7inmethodApp\Controller\HomeController::home()in/Users//Documents/ProjetSymfo4/my-project/config/routes/../../src/Controller/(whichisbeingimportedfrom"/Users//Documents/Pr

php - GCP SQL Postgres 权限问题 : can't run a query with postgres user with generated symfony db

我正在努力使用GoogleCloudPlatform的CloudSQL组件解决这个问题。我的技术栈包括在GoogleKubernetesEngine(GKE)部署中托管我的应用程序,使用CloudSQL代理sidecar连接到pod内的数据库。后端是一个Symfony项目。我按照以下步骤创建和填充数据库(没有成功):创建CloudSQLPostgres实例将代理添加到k8s容器以使用所有凭据连接到CloudSQL实例,如GCPdocumentation中所述进入我的Symfony(phpfpm)pod并运行命令phpbin/consoledoctrine:schema:update--

php - 基于 Symfony 2 的项目的安全性和登录

我正在开发一个基于Symfony2PHP框架的网络应用程序。它有一个注册用户的登录页面。我想为每个登录系统的用户执行一些自定义逻辑。基本上,我想在任何用户登录系统时记录,但我不想在主页的Controller上执行此操作,因为每次用户重新加载主页时它都会记录。我还想实现一个在用户登录系统时调用的函数,这样我就可以决定是否授予任何用户访问权限(基于存储在用户数据库中的全套信息)。我怎样才能做到这一点? 最佳答案 对于您问题的第一部分,我有类似的东西(例如,存储用户登录的最后日期和时间)。我沿着事件触发的服务路线走下去。在您的服务配置中(